home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: in2.uu.net!world!klanza
- From: klanza@world.std.com (Kurt J Lanza)
- Subject: Re: confusion between putchar and printf
- Message-ID: <Do4GwL.Kv4@world.std.com>
- Organization: The World Public Access UNIX, Brookline, MA
- References: <4i1v2n$30o@news.azstarnet.com>
- Date: Mon, 11 Mar 1996 21:26:45 GMT
-
- Howard Salmon <captarm@azstarnet.com> writes:
-
- >K & R (section 1.5) states that "putchar(c) prints the contents of the
- >integer variable c as a character, usually on the screen".
-
- >Here's a small program that I wrote testing putchar. Why doesn't it
- >compile?
-
- >#include <stdio.h>
- ># define A "hello world!"
-
- >main()
- >{
- > int c;
- > c = A; (1)
- > putchar(A); (2)
- >}
-
- >Thanks,
- > Howard Salmon (captarm@azstarnet.com)
-
- What did the compiler say? Something about invalid type, I
- wouls suspect. You have defined A as a character pointer.
- (1) You can't assign a character pointer to an integer.
- (2) Putchar() prints a single integer as a single character
- -- this won't do what you want. It looks like you badly need
- an intro to C programming. Hope this helps.
- --
- --
- Kurt J. Lanza <kjl@infor.com>
-